package xinyu.customer.util;

import android.content.Context;
import android.text.TextUtils;
import android.util.Log;

import xinyu.customer.JGApplication;
import xinyu.customer.bean.UserEntity;

/**
 * Created by Xuze on 2018/12/19.
 */

public class SpConstant {

    public static final String TAG_IMG = "image";
    public static final String TAG_AGROA = "agora";
    public static final String TAG_JIGUAN = "jiguang";

    public static final String IM_APP_KEY = "a4dc42cba89fca4cd5472dd2";

    public static final String KEY_WECHE_CODE = "key_wechat_code";
    public static final String KEY_JG_ALIAS = "key_jg_alias";
    public static final String KEY_NOTITY_CUSTID = "key_notify_custid";//存放收到的通话请求用户id和通知对应关系
    public static final String KEY_NOTITY_ID = "key_notify_id";//存放收到的通话ID

    public static final String KEY_USER_ID = "key_user_id";
    public static final String KEY_SEK = "key_sek";
    public static final String KEY_USER_HEAD = "key_user_head";
    public static final String KEY_USER_NICK = "key_user_nick";
    public static final String KEY_USER_PHONE = "key_user_phone";
    public static final String KEY_USER_GENDER = "key_user_gender";
    public static final String KEY_USER_BD_PROVINCE = "key_user_bd_province";
    public static final String KEY_USER_BD_CITY = "key_user_bd_city";
    public static final String KEY_USER_LAT = "key_user_lat";
    public static final String KEY_USER_LNG = "key_user_lng";
    public static final String KEY_USER_IS_REPORTER = "key_user_is_reporter";
    public static final String KEY_USER_IS_VIP = "key_user_is_vip";
    public static final String KEY_USER_VIP_NUMBER = "key_user_vip_number";
    public static final String KEY_CRETE_ROOM_AUTH = "key_crektv_room";
    public static final String KEY_CRASH_OUT = "key_crash_out";

    public static final String USER_BEAUTY = "key_user_beauty";
    public static final String USER_FACE_BEAUTY = "key_user_face_beauty";

    public static final String KEY_FIRST_INSTALL = "key_first_install";


    public static final String KEY_TI_MODEL = "key_ti_model_key";

    public static final String KEY_TI_MODEL_INIT = "key_ti_model_init_key";

    public static final String KEY_GIF_JSON = "key_gif_json";

    public static final String KEY_SHAREINSTALL_CUST_ID = "key_shareinstall_custid";
    public static final String KEY_SHAREINSTALL_CUST_KEY = "key_shareinstall_custkey";
    public static final String KEY_SHAREINSTALL_WAY_KEY = "key_shareinstall_refway_key";
    public static final String KEY_NIM_TOKEN = "key_nim_token";
    public static final String KEY_MODE_KEY = "key_mode_key";
    public static final String KEY_ID_KEY = "key_id_key";
    public static final String KEY_ROOM_PIC_KEY = "room_pic_key";


    public static final String KEY_INSTALL_KEY = "key_install_key";

    public static final String KEY_ID = "id";
    public static final String KEY_OTHER_ID = "other_id";

    public static final String KEY_NAME = "name";
    public static final String KEY_MODE = "mode";


    public static final String KEY_SHARE_URL = "key_share_url";
    public static final String KEY_SHARE_FORUMID = "key_share_forumid";
    public static final String KEY_SHARE_TYPE = "key_share_forumid";
    public static final String KEY_WX_APP_ID = "key_wx_app_id";
    public static final String KEY_CALL_VIEW_NUMS = "key_call_view_nums";
    public static final String KEY_OTHER_DIALOG_NUMS = "key_other_dialog_nums";//异地登录dialog
    public static final String KEY_GROUP_AUTH_ID = "key_group_auth_id";
    public static final String KEY_RICH_LEVEL_ID = "key_rich_level_id";
    public static final String KEY_USER_FULL_CHECK= "key_user_full_check";
    public static final String KEY_ACTIVITY_POP= "key_activity_pop";
    public static final String KEY_KTV_CLAPP= "key_ktv_clapp";

    public static String getUserId() {
         if (JGApplication.context!=null){
             return (String) SPUtils.get(JGApplication.context, SpConstant.KEY_USER_ID, "");
         }
        return "";
    }

    public static String getSek() {
        return (String) SPUtils.get(JGApplication.context, SpConstant.KEY_SEK, "");
    }

    public static String getWxAppId() {
        return (String) SPUtils.get(JGApplication.context, SpConstant.KEY_WX_APP_ID, "");
    }

    public static String getUserName() {
        return (String) SPUtils.get(JGApplication.context, SpConstant.KEY_USER_NICK, "");
    }

    public static String getUserHead() {
        return (String) SPUtils.get(JGApplication.context, SpConstant.KEY_USER_HEAD, "");
    }

    public static String getUserMobile() {
        return (String) SPUtils.get(JGApplication.context, SpConstant.KEY_USER_PHONE, "");
    }

    public static String getUserBDProvince() {
        return (String) SPUtils.get(JGApplication.context, SpConstant.KEY_USER_BD_PROVINCE, "");
    }

    public static String getUserBDCity() {
        return (String) SPUtils.get(JGApplication.context, SpConstant.KEY_USER_BD_CITY, "");
    }

    public static String getUserLat() {
       String  lat= (String) SPUtils.get(JGApplication.context, SpConstant.KEY_USER_LAT, "0");

        Log.e("TAG","LAT:>login pre:>>>>>>>>>>>>>>>>"+lat);
        return lat;
    }

    public static String getUserLng() {
        Double d = 0.0;
        return (String) SPUtils.get(JGApplication.context, SpConstant.KEY_USER_LNG, "0");
    }

    public static int getGender() {
        if (isFemale()) {
            return 2;
        }
        return 1;
    }

    public static boolean isFemale() {
        return "2".equals((String) SPUtils.get(JGApplication.context, SpConstant.KEY_USER_GENDER, "0"));
    }

    public static boolean isReporter() {
        return "1".equals((String) SPUtils.get(JGApplication.context, SpConstant.KEY_USER_IS_REPORTER, "0"));
    }

    public static boolean isVip() {
        return "1".equals((String) SPUtils.get(JGApplication.context, SpConstant.KEY_USER_IS_VIP, "0"));
    }

    // is_cregroup ，is_cregroup=1表示有建群权限，is_cregroup=0 无建群权限
    public static boolean isCanCreateTeam() {
        return "1".equals((String) SPUtils.get(JGApplication.context, SpConstant.KEY_GROUP_AUTH_ID, "0"));
    }

    public static boolean isReporterUserBeauty() {
        return (boolean) SPUtils.get(JGApplication.context, SpConstant.USER_BEAUTY, true);
    }

    public static boolean isFaceTrimBeauty() {
        return (boolean) SPUtils.get(JGApplication.context, SpConstant.USER_FACE_BEAUTY, true);
    }

    public static  int  getRichLevel(){
        String  richLevel  = (String) SPUtils.get(JGApplication.context, SpConstant.KEY_RICH_LEVEL_ID, "0");//财务等级richLevel
        if (TextUtils.isEmpty(richLevel)){
            return 0;
        }
        return  Integer.valueOf(richLevel);
    }


    public static Integer getUserFullCheck() {
        return (Integer) SPUtils.get(JGApplication.context, SpConstant.KEY_USER_FULL_CHECK, 1);
    }

    /**
     * 是否第一次安装
     * @return
     */
    public static boolean isFirstInstall() {
        return (boolean) SPUtils.get(JGApplication.context, SpConstant.KEY_FIRST_INSTALL, true);
    }
    public static void setFirstInstall(boolean  isTrue) {
        SPUtils.put(JGApplication.context, SpConstant.KEY_FIRST_INSTALL, isTrue);
    }
    public static void saveUser(Context mContext, UserEntity u) {
        if (mContext == null || u == null) {
            return;
        }
        SPUtils.put(mContext, SpConstant.KEY_USER_ID, u.getCust_id());
        SPUtils.put(mContext, SpConstant.KEY_USER_HEAD, u.getCust_img());
        SPUtils.put(mContext, SpConstant.KEY_USER_NICK, u.getNickname());
        SPUtils.put(mContext, SpConstant.KEY_USER_PHONE, u.getCust_mobile());
        SPUtils.put(mContext, SpConstant.KEY_USER_GENDER, u.getCust_sex());
        SPUtils.put(mContext, SpConstant.KEY_USER_IS_REPORTER, u.getIs_reporter());
        SPUtils.put(mContext, SpConstant.KEY_USER_IS_VIP, u.getIs_vip());
        SPUtils.put(mContext, SpConstant.KEY_SEK, u.getSek());
        SPUtils.put(mContext, SpConstant.KEY_SHARE_URL, u.getShare_short_url());
        SPUtils.put(mContext, SpConstant.KEY_WX_APP_ID, u.getWxapp_id());
        SPUtils.put(mContext, SpConstant.KEY_GROUP_AUTH_ID, u.getIs_cregroup());//权限 创建群组
        SPUtils.put(mContext, SpConstant.KEY_RICH_LEVEL_ID, u.getRich_level());//财务等级
        SPUtils.put(mContext, SpConstant.KEY_USER_VIP_NUMBER, u.getIs_vipnumber());//是否是靓号
        SPUtils.put(mContext, SpConstant.KEY_CRETE_ROOM_AUTH, u.getIs_ghktv_create());
        SPUtils.put(mContext, SpConstant.KEY_CRASH_OUT, u.getIs_cash_out());

        SPUtils.put(mContext, SpConstant.KEY_GROUP_AUTH_ID, u.getIs_cregroup());
        SPUtils.put(mContext, SpConstant.KEY_USER_FULL_CHECK, u.getIs_fullcheck());



    }
//
//    public static void saveUser(Context mContext, UserCenterEntity u) {
//        if (mContext == null || u == null) {
//            return;
//        }
//        SPUtils.put(mContext, SpConstant.KEY_USER_ID, u.getCust_id());
//        SPUtils.put(mContext, SpConstant.KEY_USER_HEAD, u.getCust_img());
//        SPUtils.put(mContext, SpConstant.KEY_USER_NICK, u.getNickname());
//        SPUtils.put(mContext, SpConstant.KEY_USER_GENDER, u.getCust_sex());
//        SPUtils.put(mContext, SpConstant.KEY_USER_IS_VIP, u.getIs_vip() + "");
//    }
}
